<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="prev" href="module-operator.html" />
<link rel="parent" href="module-operator.html" />
<link rel="next" href="netdata.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>6.7.1 Mapping Operators to Functions </title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="6.7 operator  "
  href="module-operator.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="6.7 operator  "
  href="module-operator.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="7. internet Data Handling"
  href="netdata.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-operator.html">6.7 operator  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-operator.html">6.7 operator  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="netdata.html">7. Internet Data Handling</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h2><a name="SECTION008710000000000000000"></a><a name="operator-map"></a>
<br>
6.7.1 Mapping Operators to Functions 
</h2>

<p>
This table shows how abstract operations correspond to operator
symbols in the Python syntax and the functions in the
<tt class="module"><a href="module-operator.html">operator</a></tt> module.

<p>
<div class="center"><table class="realtable">
  <thead>
    <tr>
      <th class="left"  >Operation</th>
      <th class="center">Syntax</th>
      <th class="left"  >Function</th>
      </tr>
    </thead>
  <tbody>
    <tr><td class="left"   valign="baseline">Addition</td>
        <td class="center"><code><var>a</var> + <var>b</var></code></td>
        <td class="left"  ><code>add(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Concatenation</td>
        <td class="center"><code><var>seq1</var> + <var>seq2</var></code></td>
        <td class="left"  ><code>concat(<var>seq1</var>, <var>seq2</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Containment Test</td>
        <td class="center"><code><var>o</var> in <var>seq</var></code></td>
        <td class="left"  ><code>contains(<var>seq</var>, <var>o</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Division</td>
        <td class="center"><code><var>a</var> / <var>b</var></code></td>
        <td class="left"  ><code>div(<var>a</var>, <var>b</var>) #</code> without <code>__future__.division</code></td></tr>
    <tr><td class="left"   valign="baseline">Division</td>
        <td class="center"><code><var>a</var> / <var>b</var></code></td>
        <td class="left"  ><code>truediv(<var>a</var>, <var>b</var>) #</code> with <code>__future__.division</code></td></tr>
    <tr><td class="left"   valign="baseline">Division</td>
        <td class="center"><code><var>a</var> // <var>b</var></code></td>
        <td class="left"  ><code>floordiv(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Bitwise And</td>
        <td class="center"><code><var>a</var> &amp; <var>b</var></code></td>
        <td class="left"  ><code>and_(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Bitwise Exclusive Or</td>
        <td class="center"><code><var>a</var> ^ <var>b</var></code></td>
        <td class="left"  ><code>xor(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Bitwise Inversion</td>
        <td class="center"><code>~ <var>a</var></code></td>
        <td class="left"  ><code>invert(<var>a</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Bitwise Or</td>
        <td class="center"><code><var>a</var> | <var>b</var></code></td>
        <td class="left"  ><code>or_(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Exponentiation</td>
        <td class="center"><code><var>a</var> ** <var>b</var></code></td>
        <td class="left"  ><code>pow(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Identity</td>
        <td class="center"><code><var>a</var> is <var>b</var></code></td>
        <td class="left"  ><code>is_(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Identity</td>
        <td class="center"><code><var>a</var> is not <var>b</var></code></td>
        <td class="left"  ><code>is_not(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Indexed Assignment</td>
        <td class="center"><code><var>o</var>[<var>k</var>] = <var>v</var></code></td>
        <td class="left"  ><code>setitem(<var>o</var>, <var>k</var>, <var>v</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Indexed Deletion</td>
        <td class="center"><code>del <var>o</var>[<var>k</var>]</code></td>
        <td class="left"  ><code>delitem(<var>o</var>, <var>k</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Indexing</td>
        <td class="center"><code><var>o</var>[<var>k</var>]</code></td>
        <td class="left"  ><code>getitem(<var>o</var>, <var>k</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Left Shift</td>
        <td class="center"><code><var>a</var> &lt;<code>&lt;</code> <var>b</var></code></td>
        <td class="left"  ><code>lshift(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Modulo</td>
        <td class="center"><code><var>a</var> % <var>b</var></code></td>
        <td class="left"  ><code>mod(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Multiplication</td>
        <td class="center"><code><var>a</var> * <var>b</var></code></td>
        <td class="left"  ><code>mul(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Negation (Arithmetic)</td>
        <td class="center"><code>- <var>a</var></code></td>
        <td class="left"  ><code>neg(<var>a</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Negation (Logical)</td>
        <td class="center"><code>not <var>a</var></code></td>
        <td class="left"  ><code>not_(<var>a</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Right Shift</td>
        <td class="center"><code><var>a</var> &gt;&gt; <var>b</var></code></td>
        <td class="left"  ><code>rshift(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Sequence Repitition</td>
        <td class="center"><code><var>seq</var> * <var>i</var></code></td>
        <td class="left"  ><code>repeat(<var>seq</var>, <var>i</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Slice Assignment</td>
        <td class="center"><code><var>seq</var>[<var>i</var>:<var>j</var>]</code> = <var>values</var></td>
        <td class="left"  ><code>setslice(<var>seq</var>, <var>i</var>, <var>j</var>, <var>values</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Slice Deletion</td>
        <td class="center"><code>del <var>seq</var>[<var>i</var>:<var>j</var>]</code></td>
        <td class="left"  ><code>delslice(<var>seq</var>, <var>i</var>, <var>j</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Slicing</td>
        <td class="center"><code><var>seq</var>[<var>i</var>:<var>j</var>]</code></td>
        <td class="left"  ><code>getslice(<var>seq</var>, <var>i</var>, <var>j</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">String Formatting</td>
        <td class="center"><code><var>s</var> % <var>o</var></code></td>
        <td class="left"  ><code>mod(<var>s</var>, <var>o</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Subtraction</td>
        <td class="center"><code><var>a</var> - <var>b</var></code></td>
        <td class="left"  ><code>sub(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Truth Test</td>
        <td class="center"><code><var>o</var></code></td>
        <td class="left"  ><code>truth(<var>o</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Ordering</td>
        <td class="center"><code><var>a</var> &lt; <var>b</var></code></td>
        <td class="left"  ><code>lt(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Ordering</td>
        <td class="center"><code><var>a</var> &lt;= <var>b</var></code></td>
        <td class="left"  ><code>le(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Equality</td>
        <td class="center"><code><var>a</var> == <var>b</var></code></td>
        <td class="left"  ><code>eq(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Difference</td>
        <td class="center"><code><var>a</var> != <var>b</var></code></td>
        <td class="left"  ><code>ne(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Ordering</td>
        <td class="center"><code><var>a</var> &gt;= <var>b</var></code></td>
        <td class="left"  ><code>ge(<var>a</var>, <var>b</var>)</code></td></tr>
    <tr><td class="left"   valign="baseline">Ordering</td>
        <td class="center"><code><var>a</var> &gt; <var>b</var></code></td>
        <td class="left"  ><code>gt(<var>a</var>, <var>b</var>)</code></td></tr></tbody>
</table></div>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="6.7 operator  "
  href="module-operator.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="6.7 operator  "
  href="module-operator.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="7. internet Data Handling"
  href="netdata.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-operator.html">6.7 operator  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-operator.html">6.7 operator  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="netdata.html">7. Internet Data Handling</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
